import { defineStore } from 'pinia'

export const userUserInfoStore = defineStore('useUserInfoStore', {
    // 开启数据持久化
    persist: true,
    state: () => {
        return {
            userId: 0,
            username: "",
            nickname: "",
            token: "",
            avatar: "",
            phone: "",
            address: "",
            email: "",
            userInfo: {}
        }
    },
    getters: {
        getUserId() {
            return this.userId;
        },
        getPhone() {
            return this.phone;
        },
        getEmail() {
            return this.email;
        },
        getUsername() {
            return this.username;
        },
        getToken() {
            return this.token;
        },
        getAvatar() {
            return this.avatar;
        },
        getNickname() {
            return this.nickname;
        },
    },
    actions: {
        setUserInfo(userInfo) {
            this.userInfo = userInfo
        },
        setAvatar(avatar) {
            this.avatar = avatar
        }
    }
})